<template>
	<view>
		<view class="detail">
			<text class="tit">{{data.title}}</text>
			<view class="writer">{{data.writer}} · <text>{{data.dynasty}}</text></view>
			<text id="article" selectionchange="true">{{wen}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data:{},
				timer:null,
				wen:''
			}
		},
		onLoad(options) {
			this.data= '啊啊啊'
			this.wen = ''
			console.log(this.data)
			uni.setNavigationBarTitle({
				title:this.data.title
			})
			//声明一个变量，用来监听要分割的长度
			var wenlen = 0
			console.log(this.data);
			this.timer=setInterval (()=>{
				//取到data.content的第wenlen位
				this.wen  = this.data.substr(0,wenlen);
				//wenlen大于data.content的长度，停止计时器
				if(wenlen<this.data.length){
					wenlen++
				}else{
					clearInterval(this.timer);
					// return
				}
				console.log(this.wen)
			},100);
			
		},
		//监听页面返回，退出页面时清除计时器
		onBackPress() {
			clearInterval(this.timer);
		},
		methods: {
			
		}
	}
</script>

<style>
	.tit{
		text-align: center;
		color: #333333;
		font-size: 25px;
		width: 100%;
		display: block;
	}
	.writer{
		text-align: right;
		padding-right: 50px;
	}
#article{
	display: block;
	color: red;
	font-size: 16px;
	/* text-indent: 32px; */
	line-height: 30px;
	width: 90%;
	margin: 10px auto;
}
</style>